題號:11 標題:Container With Most Water 難度:Medium
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
Notice that you may not slant the container.

我的程式碼
int maxArea(int* height, int heightSize){
    int area=0,area_temp;
    int r,l,temp;
    l=0; r=heightSize-1;
    while(r>l){
        printf("%d,%d\n",r,l);
        if(height[r]>height[l]){
            area_temp =  height[l] * (r-l);
            temp = height[r];
            l++;
            while(temp> height[l]){
                if(r>l){
                    break;
                }
                l++;
            }
        }else{
            area_temp =  height[r] * (r-l); 
            temp = height[l];
            r--;
            while(temp> height[r]){
                if(r>l){
                    break;
                }
                r--;
            }
        }
        
        if(area_temp>area){
            area = area_temp;
        } 
    }
    
    return area;
}
DAY13心得
昨天要感謝台積電辣妹,今天要感謝男友給我解題提示,不然我一直超時,寫到現在覺得最難的還是特殊CASE跟時間複雜度,然後我真的要去睡了